// @ts-ignore
import Utils from "@/vue2-flow/src/utils/Common.js";

export default class BaseException<T = any> extends Error {
    private Code: number;
    private Data: T | null;
    private Message: string;

    constructor(Message: string = "未知错误", Code: number = 100, Data: T | null = null) {
        Message += ';错误码：' + Code;
        if (!Utils.IsEmpty(Data)) {
            if (typeof Data == 'string') {
                Message += ";Data:" + Data;
            }
            if (typeof Data == 'object') {
                Message += ";Data:" + JSON.stringify(Data);
            }
        }
        super(Message);
        this.Message = Message; // 赋值
        this.Code = Code;
        this.Data = Data;
        Error.captureStackTrace(this, this.constructor)
    }
}
